<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    * This is the key class to all the admin side data nodes.
    * It is extended into child classes which do all the work.
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 21.10.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/
    
    /***
    * Class adminNodeRoot
    ****
    * This class handles the editing of simple HTML root pages in INA
    ****
    * @package adminNodes
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 21.10.2005
    * @copyright essentialmind.com 2005
    ***/
    class adminNodeRoot extends adminNode{
        
		/**
         * a data processor.
         * 
         * @return 
         **/
        function process(){
            if($_POST){
                //update database record
                $this->db->Execute("UPDATE node_root SET content = '".$_POST['content']."' WHERE id = " . $this->object);
                
                //updates the status of the page (title, wf state)
                $this->updateNodeStatus();
                
                //make a note of the request
                $this->log->recordAction("Updated Root page (".$this->object.") with global id (".$this->pageref.")");
            
                header('Location: '.$this->request.'&confirm=true');
                exit;
            }else{
                $this->smarty->assign('node',$this->db->getRow("SELECT 
                                                                    objectmap.title, 
                                                                    content 
                                                                FROM objectmap
                                                                LEFT JOIN node_root ON objectmap.objectid = node_root.id 
                                                                WHERE version = 1 AND objectmap.nodeid = " . $this->noderef));
            }
        }
        
        /**
         * Will set the HTML template needed for
         * the child's operation
         * 
         * @return 
         **/
        function setTemplate(){
            $this->setActionTemplate('nodes/editFolder.html');
        }
        
        
		/** 
         * method which will handle a default add action to the
         * dedicated table
         * 
         * @return integer ID of new object
         * @see ajaxAddPage
         * @see ajaxAddNode
         **/
        function addInstance(){
            $this->db->Execute("INSERT INTO node_root(content) VALUES('')");
            return $this->db->getOne("SELECT last_value FROM node_root_id_seq");
        }
    }
?>